home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
lang
/
ace102.lha
/
include
/
sort.h
< prev
next >
Wrap
Text File
|
1993-01-30
|
670b
|
41 lines
{
* comb sort an array of strings *
Author: David Benn
Date: 29th,30th March, 4th April, 22nd July 1992
}
SUB max&(x&,y&)
if x&>y& then max&=x& else max&=y&
END SUB
SUB sort(addr&,n&)
{ - sorts up to 10000 elements
in a string array.
- addr&=address of array.
- n&=# of elements in array.
}
const true=-1
const false=0
longint swapped,swaps
single gap
dim n$(10000) address addr&
swapped=true
gap=n&
while swapped or gap<>1
swapped=false
gap=max&(int(gap/1.3),1)
for i=0 to n&-gap
if n$(i)>n$(i+gap) then
temp$=n$(i)
n$(i)=n$(i+gap)
n$(i+gap)=temp$
swapped=true
++swaps
end if
next
wend
END SUB